package com.zhangxiaofanfan.hotcode.second;

/**
 *
 * @date 2024-07-13 03:14:13
 * @author zhangxiaofanfan
 */
public class HotCode087 {
    public static void main(String[] args) {
        HotCode087 hotCode = new HotCode087();
        int[] nums = {7,7,7,7,7,7,7};
        System.out.println(hotCode.lengthOfLIS(nums));
    }

    public int lengthOfLIS(int[] nums) {
        if (nums == null || nums.length == 0) {
            throw new RuntimeException("入参不满足条件");
        }
        int maxLength = 1;
        int[] dp = new int[nums.length];
        for (int before = 0, after = 0; after < nums.length; after++) {
            dp[after] = 1;
            for (before = after - 1; before >= 0; before--) {
                if (nums[before] < nums[after]) {
                    dp[after] = Math.max(dp[after], dp[before] + 1);
                }
                if (dp[after] - 1 > before) {
                    break;
                }
            }
            maxLength = Math.max(maxLength, dp[after]);
        }
        return maxLength;
    }
}